<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <h1>JavaScript 数组排序</h1>
  <p>从大到小：<span id="demo"></span></p>
</head>
<body>
<script>
  var a= [5,1,8,10,4];
  a.sort(function(x,y){return y-x});
  document.getElementById("demo").innerHTML = a;// should output: [10,8,5,4,1]
</script>
</body>
</html>